/*Emamul Islam Emon.      Id No: 093-15-844

4)	Example of Bubble Sort. */




#include<stdio.h>
#include<conio.h>

#define N 10

int A[N];

void Swap(int *n1, int *n2){
  int temp;
  temp = *n1;
  *n1   = *n2;
  *n2   = temp;
}

void Bubblesort(int size){
  int to_do, index;
  to_do = size-2;

  while(to_do >= 0){
    index = 0;
    while(index <= to_do){
      if(A[index] > A[index + 1])
	Swap(&A[index], &A[index + 1]);
      index = index + 1;
    }
    to_do = to_do - 1;
  }
}

void main(){
  int c,i;
  //int A[N];
  clrscr();
  printf("Plz enter how many data u would like to sort(Not more than 10):");
  scanf("%d",&c);
  printf("Plz enter the data u would like to sort:");
  for(int i=0;i<c;i++){
	scanf("%d",&A[i]);
  }
  printf("Unsorted Data:");
  for(i=0;i<c;i++){
	printf("%d ",A[i]);
  }
  Bubblesort(c);
  printf("Sorted Data:");
  for(i=0;i<c;i++){
	printf("%d ",A[i]);
  }
  getch();
}




















































